package com.euond.accv.mdm.service;

import com.euond.accv.mdm.client.dto.MdmStoreDTO;
import com.euond.accv.mdm.dao.MdmStoreDao;
import com.euond.accv.mdm.domain.MdmStore;
import com.euond.common.dao.BaseDao;
import com.euond.common.service.BaseSimplePageService;
import com.euond.common.util.BeanMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("mdmStoreService")
public class MdmStoreService extends BaseSimplePageService<MdmStore, String>{
	@Autowired
	public MdmStoreDao dao;
	
	@Override
	protected BaseDao<MdmStore, String> init() {
		return dao;
	}

	public List<MdmStoreDTO> findStoreByNo(String customerNo){
		List<MdmStore> dtoList = dao.findByStoreNo(customerNo);

		List<MdmStoreDTO> list = new ArrayList<MdmStoreDTO>();
		if(dtoList!=null && dtoList.size()>0){
			list = BeanMapper.mapList(dtoList, MdmStoreDTO.class);
		}
		return list;
	}
}
